        <link rel="stylesheet" type="text/css" href="<?php echo base_url()?>/public/assets/css/mybag.css">

        <!--顶部-->
        <div class="weui_navbar">
            <article class="weui_article">
                <h1>您正在进行转单</h1>
            </article>
        </div>
        
        
        
        <div class="mainfo">
           <p class="text">上课老师
                <span class="fr" id="teacher">修改老师<i class="fa fa-angle-right"></i></span>
            </p>
            
          <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg">
                <div class="weui_media_hd">
                    <img class="weui_media_appmsg_thumb" id="te_img" src="<?php echo $teacher_info['avatar']?>" alt="<?php echo $teacher_info['name']?>">
                </div>
                <div class="weui_media_bd">
                    <h4 class="weui_media_title" id="te_name"><?php echo $teacher_info['name']?></h4>
                </div>
            </a>
            <p class="text" id="timetable_list">
                <em class="fl">上课时间</em>
                <span class="choose fr" id="timetable">修改时段</span>
            </p>
            <section class="timeline" id="timeline">
            <span class="time"><?php echo $book_info['book_date']?><?php echo mb_substr($book_info['book_date_start'],0,5,'utf-8')?>~<?php echo mb_substr($book_info['book_date_end'],0,5,'utf-8')?></span>
            <span class="cross"></span>
            </section>
        </div>
                  
        <div class="weui_btn_area">
            <a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default">取消</a>
            <a href="javascript:validate();" class="weui_btn weui_btn_mini weui_btn_primary">确认</a>
        </div>
        
        <!--选择上课老师-->
        <div class="weui_dialog_confirm" id="chooseTeacher" style="display: none;">
            <div class="weui_mask"></div>
            <div class="weui_dialog">
                <div class="weui_dialog_hd"><strong class="weui_dialog_title">选择上课老师</strong></div>
                <div class="weui_cells weui_cells_radio">
                <?php foreach ($teacher_list as $val){?>
                    <label class="weui_cell weui_check_label" for="x<?php echo $val['id']?>">
                        <div class="weui_cell_bd weui_cell_primary">
                            <!-- 正式打开
                            <img id="te_img_<?php echo $val['id']?>" src="<?php echo $val['avatar']?>">
                             -->
                            <img id="te_img_<?php echo $val['id']?>" src="<?php echo base_url()?>/public/assets/images/class.jpg">
                            <div class="teacher">
                                <p id="te_name_<?php echo $val['id']?>" ><?php echo $val['name']?></p>
                                <p><?php echo $val['explain']?></p>
                                <p>已上<?php echo $val['book_num']?>节课</p>
                            </div>
                        </div>
                        <div class="weui_cell_ft">
                            <input type="radio" class="weui_check" name="teacher_id" value="<?php echo $val['id']?>" id="x<?php echo $val['id']?>">
                            <span class="weui_icon_checked"></span>
                        </div>
                    </label>
                <?php }?>
                    <!-- 
                    <label class="weui_cell weui_check_label" for="x12">

                        <div class="weui_cell_bd weui_cell_primary">
                            <img src="images/pic.jpg">
                            <div class="teacher">
                                <p>柯柯老师</p>
                                <p>支持方庄半径5公里范围内上课</p>
                                <p>已上588节课</p>
                            </div>
                        </div>
                        <div class="weui_cell_ft">
                            <input type="radio" name="radio1" class="weui_check" id="x12" checked="checked">
                            <span class="weui_icon_checked"></span>
                        </div>
                    </label>
                     -->
                </div>
                <div class="weui_dialog_ft">
                    <a href="javascript:;" id="teacher_off" class="weui_btn_dialog default">取消</a>
                    <a href="javascript:;" id="teacher_on" class="weui_btn_dialog primary">确定</a>
                </div>
            </div>
        </div>
        
        <!--选择时间-->
        <div class="weui_dialog_confirm" id="chooseTime" style="display: none;">
            <div class="weui_mask"></div>
            <div class="weui_dialog">
                <div class="weui_dialog_hd"><strong class="weui_dialog_title">选择上课时间</strong></div>
                
                <div class="weui_cells weui_cells_radio" id="teacher_time">
                
                </div>
                <div class="weui_dialog_ft">
                    <a href="javascript:;" id="teacher_time_off" class="weui_btn_dialog default">取消</a>
                    <a href="javascript:;" id="teacher_time_on" onClick="time_on();" class="weui_btn_dialog primary">确定</a>
                </div>
            </div>
        </div>
        <form action="/courserecord/resetbook" id="myfrom" method="post">
        <input type="hidden" value="ok" name="form_submit" />
		<input type="hidden" value="<?php echo $teacher_info['id']?>" name="hi_teacher_id" />
		<input type="hidden" value="<?php echo $book_id;?>" name="book_id" />
		<input type="hidden" value="<?php echo $book_info['book_date']?>" name="date" />
		<input type="hidden" value="<?php echo mb_substr($book_info['book_date_start'],0,5,'utf-8')?>~<?php echo mb_substr($book_info['book_date_end'],0,5,'utf-8')?>" name="time" />
		<textarea name="message" style="display:none"></textarea>
		</form>
<!-- 弹框2 -->
<div class="weui_dialog_alert" id="dialog2" style="display:none">
<div class="weui_mask"></div>
<div class="weui_dialog">
    <div class="weui_dialog_hd"><strong id="dialog2_content" class="weui_dialog_title">&nbsp;</strong></div>
    <div class="weui_dialog_ft">
        <a href="javascript:$('#dialog2').hide();" class="weui_btn_dialog primary">确定</a>
    </div>
</div>
</div>
<!-- 弹框1 -->
<div class="weui_dialog_confirm" id="dialog1" style="display:none">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd" ><strong id="dialog1_content" class="weui_dialog_title">&nbsp;</strong></div>
        <div class="weui_dialog_ft">
            <a href="javascript:$('#dialog1').hide();" class="weui_btn_dialog default">取消</a>
            <a href="javascript:;" id="dialog1_ok" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>

    <script type="text/javascript">
        var _index = 0;
        $(document).ready(function(){
            $("#teacher").bind("click",function(){
                $("#chooseTeacher").show();
            });
            //取消
            $("#teacher_off").bind("click",function(){
                $("#chooseTeacher").hide();
            });
            //确认
            $("#teacher_on").bind("click",function(){
            	$("#chooseTeacher").hide();
            	//切换老师，删除所有session
//         	    $.ajax({
//         	        type: 'get',
//         	        url: '/purchasecourse/deltimesessionall',
//         	        async : false,
//         	        dataType: 'json',
//         	        success: function (d){
//             	        if(d['code'] == 10){
                            var teacher_id = check_radio('teacher_id');
                            $('#te_img').attr('src',$('#te_img_'+teacher_id).attr('src'));
                            $('#te_name').html($('#te_name_'+teacher_id).html());
                            $("[name='hi_teacher_id']").val(teacher_id);
                            $('#timeline').html('');
//                 	    }else{
//                     	    //alert(d['msg']);
//                 	    	dialog2(d['msg']);
//                     	}
//         	        },
//         		});
            });

            //添加上课时间
            $("#timetable").bind("click",function(){
            	var teacher_id = $("[name='hi_teacher_id']").val();
            	if(typeof(teacher_id) == "undefined" || teacher_id <= 0){
            	    //alert('请先选择教师');
            	    dialog2('请先选择教师');
            	    return false;
                }
//                 var $course_package_id = $("[name='course_package_id']").val();
//                 if(typeof($course_package_id) == "undefined" || !$course_package_id || $course_package_id == 0){
//                     //alert('课包ID异常');
//                     dialog2('课包ID异常');
//                     return false;
//                 }
//                 var $order_id = $("[name='order_id']").val();
//                 if(typeof($order_id) == "undefined" || !$order_id || $order_id == 0){
//                     //alert('订单ID异常');
//                     dialog2('订单ID异常');
//                     return false;
//                 }
        	    $.ajax({
        	        type: 'get',
        	        url: '/courserecord/teachertime?teacher_id=' + teacher_id,
        	        async : false,
        	        dataType: 'json',
        	        success: function (d){
            	        if(d['code'] == 10){
            	        	$('#teacher_time').html(d['list']);
            	        	$("#chooseTime").show();
            	            $(".daytab p").bind("click",function(){
            	                _index = $(this).index();
            	                var _ul = $(".timetab ul").get(_index);
            	                var path_a = $(".daytab p");
            	                var path_b = $(".timetab ul");
            	                path_a.not($(this).addClass("on")).removeClass("on");
            	                path_b.not($(_ul).show()).hide();
            	                $(".timetab li").removeClass("on");

            	                var _li = $(".timetab ul li:first-child").get(_index);
            	                $(_li).addClass("on");
            	                //alert($(_li).text());
            	                //$(_ul).eq(0).addClass("on");
            	                //path_b.not($(0).addClass("on")).removeClass("on");
            	                //day = $(this).text();
            	            });
            	            $(".timetab li").bind("click",function(){
            	                var path_c = $(".timetab li");
            	                path_c.not($(this).addClass("on")).removeClass("on");
            	                //time = $(this).text();
                                //finnalTime = day + time;
            	            });
                	    }else{
                    	    //alert(d['msg']);
                    	    dialog2(d['msg']);
                    	}
        	        },
        		});
            });
            $("#teacher_time_off").bind("click",function(){
                $("#chooseTime").hide();
            });
        });
        //单选框值
        function check_radio(name){
            var chkObjs = document.getElementsByName(name);
            for(var i=0;i<chkObjs.length;i++){
                if(chkObjs[i].checked){
                    return chkObjs[i].value;
                }
            }
        }
        function time_on(){
            var day = $('.daytab .on').text();
            if(typeof(day) == "undefined" || !day){
                //alert('请选择日期');
                dialog2('请选择日期');
                return false;
            }
            var time = $('.timetab .on').text();
            if(typeof(time) == "undefined" || !time){
                //alert('请选择时间');
                dialog2('请选择时间');
                return false;
            }
            $("[name='date']").val(day);
            $("[name='time']").val(time);
        	var content = '';
        	content += '<span class="time">'+day+time+'</span>';
     		content += '<span class="cross"></span>';
            $('#timeline').html(content);
            $("#chooseTime").hide();
        }
        //删除选择时间
//         function del_timeline(obj){
//             //已删除的时间，删除相应
//         	var _text = $(obj).parent().eq(0).text();
//     	    $.ajax({
//     	        type: 'get',
//     	        url: '/purchasecourse/deltimesession?set_date='+_text,
//     	        async : false,
//     	        dataType: 'json',
//     	        success: function (d){
//         	        if(d['code'] == 10){
//         	        	$(obj).parent().remove();
//             	    }else{
//             	    	dialog2(d['msg']);
//                 	}
//     	        },
//     		});
//         }
        function validate(){
            var $liuyan = $('#liuyan').val();
            var $teacher_id = $("[name='hi_teacher_id']").val();
            if(typeof($teacher_id) == "undefined" || !$teacher_id || $teacher_id==0){
                //alert('请选择上课教师');
                dialog2('请选择上课教师');
                return false;
            }
            var $timeline = $('.timeline').html();
            if(typeof($timeline) == "undefined" || !$timeline){
                //alert('请选择上课时间');
                dialog2('请选择上课时间');
                return false;
            }
            var $book_id = $("[name='book_id']").val();
            if(typeof($book_id) == "undefined" || !$book_id || $book_id == 0){
                //alert('订单ID异常');
                dialog2('约课ID异常');
                return false;
            }
            var $date = $("[name='date']").val();
            //alert($date);
            if(typeof($date) == "undefined" || !$date || $date == 0){
                //alert('课包ID异常');
                dialog2('日期异常');
                return false;
            }
            var $time = $("[name='time']").val();
            //alert($time);
            if(typeof($time) == "undefined" || !$time || $time == 0){
                //alert('课包ID异常');
                dialog2('时间异常');
                return false;
            }
            
    	    $('#dialog1_content').html('确定提交吗？');
    	    $('#dialog1').show();
            $("#dialog1_ok").bind("click",function(){
            	$('#dialog1').hide();
                $("[name='message']").val($liuyan);
//         	    $.ajax({
//         	        type: 'get',
//         	        url: '/courserecord/isteachertime?hi_teacher_id='+$teacher_id+'&date='+date+'&time='+time,
//         	        async : false,
//         	        dataType: 'json',
//         	        success: function (d){
//             	        if(d['code'] == 10){
             	        	document.getElementById('myfrom').submit();
//                 	    }else{
//                     	    //alert(d['msg']);
//                     	    dialog2(d['msg']);
//                     	}
//         	        },
//         		});
            });
            
//             if(confirm("你确定提交吗？")){
//                 $("[name='message']").val($liuyan);
//         	    $.ajax({
//         	        type: 'get',
//         	        url: '/purchasecourse/isteachertime?hi_teacher_id='+$teacher_id,
//         	        async : false,
//         	        dataType: 'json',
//         	        success: function (d){
//             	        if(d['code'] == 10){
//             	        	document.getElementById('myfrom').submit();
//                 	    }else{
//                     	    //alert(d['msg']);
//                     	    dialog2(d['msg']);
//                     	}
//         	        },
//         		});
//             }

      	  //document.getElementById('myform').submit();
      	}
        function dialog2(content){
    	    $('#dialog2_content').html(content);
    	    $('#dialog2').show();
        }
    </script>
